home *** CD-ROM | disk | FTP | other *** search
/ BMUG Revelations / BMUG Revelations.toast / Programming / Programming Languages / Yerk 3.64 / System source / String < prev    next >
Text File  |  1991-11-11  |  3KB  |  73 lines

  1. \ String
  2. \  5/25/84  NDI Version 1
  3. \ 10/13/84  CBD string: is now get:, added put:
  4. \                Removed length:, curpos, works like Ordered-Col
  5. \ 12/29/84  cbd Converted to heap-based string
  6. \  1/15/85  cbd Split into BasicStr, String
  7. \  7/23/85  cdn Fixed charOf: method; Added fill: method
  8. \                Removed unused word ab0
  9. \  8/25/86  cdn Changed charOf: & indexOf: to leave current offset 1 byte later
  10. \  7/02/90    rfl    fixed =: so that the source is locked during xfer
  11. \  9/27/90    rfl    modified using getstate and setstate
  12. \ 11/11/91    rfl    simplified fill: 
  13.  
  14. Decimal
  15.  
  16. \ String is a dynamic heap based string object that can grow and shrink
  17. :CLASS String  <Super BasicStr
  18.  
  19.     \ ( -- offs ) return the current offset
  20.     :M  WHERE:  get: offset ;M
  21.  
  22.     \ move to the 0th byte in the string
  23.     :M  START:  0 moveTo: self ;M
  24.  
  25.     \ assign this string to any object that accepts addr len
  26.     :M  =: { destObj -- }  getState: self lock: self get: self put: destObj setState: self ;M
  27.  
  28.     \ use for concatenating the receiving object data to the end of the data
  29.     \ of the object on the stack
  30.     \ same as add: except that the thing on the stack is another handle
  31.     \ and the destination is on the stack. 
  32.     :M  CONCAT: { destObj -- } getState: self lock: self get: self add: destObj setState: self ;M
  33.  
  34.     \ ( chr len -- )  clear the string and set it to len bytes of chr
  35.     :M  FILL:   setSize: self get: self rot Fill ;M
  36.  
  37.     \ name an object using this string
  38.     :M  NAME=: { destObj -- }  getState: self lock: self get: self  name: destObj setState: self ;M
  39.  
  40.     \ ( len -- )  return the substring starting at offset
  41.     :M  SUBSTR: { len -- addr len } get: offset 0< classErr" 151
  42.         ptr: self  get: offset +
  43.         size: self  get: offset -  len min  0 max ;M
  44.  
  45.     :M  DELETE:  { addr len -- }  addr len addr 0 replace: self ;M
  46.  
  47.     :M  INDEXOF: { addr len -- offs }  addr len 0 0 replace: self
  48.         get: offset dup 0<
  49.         IF  drop false
  50.         ELSE true
  51.         THEN ;M
  52.  
  53.     \ ( char -- offs t OR f )  find a single character in the string
  54.     :M  CHAROF:  pad c! pad 1 indexof: self ;M
  55.  
  56.     \ ( ^fcb -- rc )  Fill string from file object
  57.     :M  READ:  { theFcb len -- rc }  len setsize: self
  58.         get: self  read: thefcb
  59.         bytesRead: thefcb  setSize: self ;M
  60.  
  61.     \ ( ^fcb -- rc )  Fill string from file object
  62.     :M  READLINE:  { theFcb len -- rc }  len setSize: self
  63.         get: self  readLine: thefcb
  64.         bytesRead: thefcb  setSize: self ;M
  65.  
  66.     \ ( rect just -- )  draw string justified in rect
  67.     :M  DRAW:  { tRect just -- } ptr: self +base  size: self
  68.         tRect +base just makeInt $ a9ce trap ( call TextBox ) ;M
  69.  
  70. ;CLASS
  71.  
  72. <" Files
  73.